package Opertion;

import Book.Book;
import Book.BookList;
import com.sun.nio.sctp.SctpChannel;

import java.util.Arrays;
import java.util.Scanner;

public class AddBook implements IOPertion{
    @Override
    public void operte(BookList bookList) {
        System.out.println("添加图书");
        if(bookList.NOW_BOOK_SIZE == bookList.SIZE_BOOK) {
            bookList.books = Arrays.copyOf(bookList.books,bookList.SIZE_BOOK*2);
        }
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入要添加的图书的名字");
        String name = scanner.nextLine();

        System.out.println("请输入要添加的图书的作者");
        String author = scanner.nextLine();

        System.out.println("请输入要添加的图书的价格");
        int price = scanner.nextInt();

        scanner.nextLine();

        System.out.println("请输入要添加的图书的类型");
        String type = scanner.nextLine();
        int choice = bookList.NOW_BOOK_SIZE;
        Book book = new Book(name,author,price,type);
        bookList.setBooks(choice,book);
        System.out.println("添加成功");
        bookList.NOW_BOOK_SIZE++;
    }
}
